#include <cstdio>
#include <iostream>
#include <string>

#define MAXN 101

using namespace std;

int nextBracketPos(int startPos, string s) {
    for (int i = startPos + 1; i < s.length(); i++) {
        if (s[i] == ')') return i;
    }
	return s.length() - 1;
}

int handle(string s) {
	int numListIndex = 0;
    int numList[MAXN];
    int opList[MAXN];
    int numStack[MAXN];
	int numStackIndex = 0;
    int opStack[MAXN];

	int i = 0;

    numListIndex = 0;
    opList[0] = 0;
    numStackIndex = 0;
    opStack[0] = 0;

    string numTmp = "";

    bool isMinus = false;
    while (i < s.length()) {
        if (s[i] >= '0' && s[i] <= '9') {
            numTmp += s[i];
        } else {
            if (numTmp != "") {
                numList[++numListIndex] = atoi(numTmp.c_str());
                numTmp = "";

				/*
				if (isMinus) {
					numList[numListIndex] = -numList[numListIndex];
					opList[++opList[0]] = '+';
					isMinus = false;
				}*/
            } else if (s[i] == '-' && numListIndex == 0) {
				numList[++numListIndex] = 0;
				//numList[++numListIndex] = 0;
				//isMinus = true;
			}
            switch (s[i]) {
				case '+':
				case '-':
				case '*':
				case '/':
					/*
					if (isMinus && s[i] == '-') {
						break;
					}*/
					opList[++opList[0]] = s[i];
					break;
				case '(':
					int pos = nextBracketPos(i, s);
					numList[++numListIndex] = handle(s.substr(i + 1, pos - i - 1));
					i = pos;
					continue;
					break;
            }
        }

        i++;
    }

    if (numTmp != "") {
        numList[++numListIndex] = atoi(numTmp.c_str());

		/*
		if (isMinus) {
			numList[numListIndex] = -numList[numListIndex];
			isMinus = false;
		}*/
    }

    int numHead = 1;
    numStack[++numStackIndex] = numList[numHead++];

    for (i = 1; i <= opList[0];) {
        switch (opList[i]) {
            case '+':
				numStack[++numStackIndex] = numList[numHead++];
                opStack[++opStack[0]] = opList[i++];
				break;
            case '-':
                numStack[++numStackIndex] = numList[numHead++];
                opStack[++opStack[0]] = opList[i++];
				//numStack[numStackIndex] = -numStack[numStackIndex];
                break;
            case '*':
                numStack[numStackIndex] *= numList[numHead++];
                i++;
                break;
            case '/':
				if (numList[numHead] == 0) {
					numStack[numStackIndex] = 0;
					numHead++;
				} else 
                numStack[numStackIndex] /= numList[numHead++];
                i++;
                break;
            default:
                i++;
                break;
        }
    }

    // Calculate

	for (i = 1; i <= opStack[0]; i++) {
		if (opStack[i] == '-') {
			numStack[i + 1] = -numStack[i + 1];
		}
	}
	int ans = 0;
	for (i = 1; i <= numStackIndex; i++) {
		ans += numStack[i];
	}
/*
    int ans = numStack[numStackIndex--];
    while (numStackIndex) {
        if (opStack[opStack[0]--] == '+') {
            ans += numStack[numStackIndex--];
        } else {
            ans = numStack[numStackIndex--] - ans;
        }
		//ans += numStack[numStackIndex--];
    }*/

    return ans;
}

int main() {
    cout << "Input" << endl;
    string s;
    cin >> s;
    cout << "Output" << endl;
	int ans = handle(s);
    cout << ans << endl;
    cout << "End" << endl;

    return 0;
}
